// Copyright 2011 Bryan McKelvey, MIT License

/**
 * @fileoverview The Background singleton and the methods available to it
 * @author bryan.mckelvey@gmail.com (McKelvey Bryan)
 */

/**
 * This class interacts with the background page, creating listeners for use with content scripts
 * @constructor
 */
var Background = (function() {
  /** Sets up a listener to evaluate requests from content scripts */
  function setRequestListener() {
    chrome.extension.onRequest.addListener(function(request, sender, respond) {
      switch (request.type) {
        case "options":
          respond(Settings.all());
          break;
        default:
          respond({});
          break;      
      }
    });
  }

  return {
    /** Loads the request listeners to the background page */
    load: function() {
      setRequestListener();
    }
  }
})();

Settings.load();
Background.load();